/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxinline.servico;

import br.com.foxinline.modelo.Protocolo;
import br.com.foxinline.modelo.Tramite;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author ely
 */

@Stateless
public class TramiteServico extends ServicoGenerico<Tramite> {
    
    public TramiteServico(){
        super(Tramite.class);
    }
    
   public List<Tramite> findTramite(Protocolo protocolo) {
        String sql = "SELECT t FROM Protocolo p JOIN p.tramites t WHERE p.numero = :num";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("num", protocolo.getNumero());
        return (List<Tramite>) query.getResultList();
    }
    
}
